package ru.spbu.mm.diploma.common.entity;

import org.hibernate.annotations.*;
import org.hibernate.annotations.NamedQueries;
import org.hibernate.annotations.NamedQuery;

import javax.persistence.*;
import javax.persistence.Entity;

import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User: Ksushenka
 * Date: 29.10.11
 * Time: 18:03
 * To change this template use File | Settings | File Templates.
 */
@NamedQueries({
	@NamedQuery(
	name = "findRiskByRiskGroup",
	query = "from Risk r where r.id in (select rg.riskId from RiskGroupMapping rg where rg.riskGroupId=:groupId)"
	),
    @NamedQuery(
	name = "findByName",
	query = "from Risk r where r.name=:riskName"
	)
})
@Entity
public class Risk {
    private Integer id;
    private String name;
    private String description;
    private double commonValue;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public double getCommonValue() {
        return commonValue;
    }

    public void setCommonValue(double commonValue) {
        this.commonValue = commonValue;
    }
    @Override
    public String toString(){
        return "id:"+this.id+
                "name:"+this.name+
                "description:"+this.description+
                "commonValue:"+ this.commonValue;
    }
}
